// Created by WXX on 2021/9/28 10:50
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

/**
 * 执行用时：16 ms, 在所有 C++ 提交中击败了61.06%的用户
 * 内存消耗：11.7 MB, 在所有 C++ 提交中击败了29.80%的用户
 */
class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        vector<int> nums = score;
        sort(nums.begin(), nums.end(), greater<int>());
        unordered_map<int, int> map;
        for (int i = 0; i < nums.size(); i++) map[nums[i]] = i + 1;

        vector<string> res;
        for (auto x : score) {
            if (x == nums[0]) res.push_back("Gold Medal");
            else if (x == nums[1]) res.push_back("Silver Medal");
            else if (x == nums[2]) res.push_back("Bronze Medal");
            else res.push_back(to_string(map[x]));
        }
        return res;
    }
};

void OutputBasicArray1D(vector<string> nums) {
    cout << "[";
    for (int i = 0; i < nums.size(); i++) {
        cout << nums[i];
        if (i != nums.size() - 1) cout << ", ";
    }
    cout << "]" << endl;
}

int main() {

    vector<int> nums = {5, 4, 3, 2, 1};
    OutputBasicArray1D(Solution().findRelativeRanks(nums));

    return 0;
}
